package cn.itcast.controller;

import cn.itcast.pojo.Emp;
import cn.itcast.pojo.LogInfo;
import cn.itcast.pojo.Result;
import cn.itcast.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/login")
public class LogController {
    @Autowired
    private EmpService empService;
    @PostMapping
    public Result login(@RequestBody Emp emp) {
        LogInfo login = empService.login(emp.getUsername(), emp.getPassword());
        return login == null ? Result.error("登录失败") : Result.success("登录成功", login);
    }
}
